package com.pepper.jenkins_spring_demo1.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.crypto.interfaces.PBEKey;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@RestController
public class HelloContrller {

    @GetMapping("")
    public String index(){
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern( "yyyy/MM/dd HH:mm:ss" );
        LocalDateTime now = LocalDateTime.now();
        String strNow = dtf.format(now);
        String resp = "Jenkins index now: " + strNow ;
        System.out.println(resp);
        return resp;
    }

    @GetMapping("/test")
    public String test(){
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern( "yyyy/MM/dd HH:mm:ss" );
        LocalDateTime now = LocalDateTime.now();
        String strNow = dtf.format(now);
        String resp = "Jenkins test, now: " + strNow ;

        System.out.println(resp);
        return resp;
    }
    @GetMapping("/getjdk")
    public String getjdk(){
        String arch = System.getProperty("os.arch");
        String vmName = System.getProperty("java.vm.name");
        String jdkVersion = System.getProperty("java.version");
        String resp = arch + "_"+ vmName + "_" + jdkVersion;
        System.out.println(resp);
        return resp;


    }
}
